package com.ulic.customerManApplication.mailmodule.bo;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.ulic.customerManApplication.membermodule.bo.Member;
import com.ulic.customerManApplication.usermodule.bo.User;
@Entity
@Table(name="T_GYW_MAILRECORD")
@SequenceGenerator(name="mailRecord_seq",sequenceName="S_GYW_MAILRECORD_ID")
public class MailRecord implements Serializable{

	/**
	 * 邮件发送记录
	 */
	private static final long serialVersionUID = 1L;
	private int mail_id;//编号
	private User sender;//发送人
	private String theme;//主题
	private String content;//内容
	private String attachments;//附件
	private Set<Member> addressees = new HashSet<Member>();//收件人 
	private Set<Member> copiesTo = new HashSet<Member>();//抄送人
	private String sendTime;//发送时间
	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="mailRecord_seq")
	public int getMail_id() {
		return mail_id;
	}
	public void setMail_id(int mailId) {
		mail_id = mailId;
	}
	@ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY, optional = false)   
    @JoinColumn(name="UM_USER_ID")
	public User getSender() {
		return sender;
	}
	public void setSender(User sender) {
		this.sender = sender;
	}
	public String getTheme() {
		return theme;
	}
	public void setTheme(String theme) {
		this.theme = theme;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getAttachments() {
		return attachments;
	}
	public void setAttachments(String attachments) {
		this.attachments = attachments;
	}
    @ManyToMany(cascade = CascadeType.REFRESH)   
    @JoinTable(name = "t_gyw_member_mailrecord", inverseJoinColumns = @JoinColumn(name = "id"), joinColumns = @JoinColumn(name = "mail_id")) 
	public Set<Member> getAddressees() {
		return addressees;
	}
	public void setAddressees(Set<Member> addressees) {
		this.addressees = addressees;
	}
	@ManyToMany(cascade = CascadeType.REFRESH)   
    @JoinTable(name = "t_gyw_copies_member_mailrecord", inverseJoinColumns = @JoinColumn(name = "id"), joinColumns = @JoinColumn(name = "mail_id")) 
	public Set<Member> getCopiesTo() {
		return copiesTo;
	}
	public void setCopiesTo(Set<Member> copiesTo) {
		this.copiesTo = copiesTo;
	}
	public String getSendTime() {
		return sendTime;
	}
	public void setSendTime(String sendTime) {
		this.sendTime = sendTime;
	}
	 
	
}
